package cn.zh.base.controller;

import cn.zh.base.dto.LoginDto;
import cn.zh.base.dto.WeChatDto;
import cn.zh.base.dto.WechatBinderDto;
import cn.zh.base.service.LoginService;
import cn.zh.base.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService service;

    @PostMapping("/account")
    public AjaxResult account(@RequestBody @Valid LoginDto dto) {
        return service.login(dto);
    }

    @PostMapping("/wechat")
    public AjaxResult wechat(@RequestBody @Valid WeChatDto dto) {
        return service.wechat(dto);
    }

    @PostMapping("/wechat/binder")
    public AjaxResult wechatBinder(@RequestBody @Valid WechatBinderDto dto)
    {
        return service.wechatBinder(dto);
    }

}
